var app = getApp(),
  $ = require("../../utils/httpHelper.js");
var address = require('../../utils/city.js')

Page({
  data: {
    height: 0,
    balance:0.00,
    paymoney:''
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({ height: res.windowHeight })
      }
    })
    let par = {
      rd_session: app.globalData.userInfo.rd_session
    }
  },

  bindKeyInput: function (e) {
    this.setData({
      paymoney: e.detail.value
    })
  },
 

  topay(){
    if (!app.check_empty(this.data.paymoney)){
      let par = {
        rd_session: app.globalData.userInfo.rd_session,
        mendian_id: this.data.bankno,
        total_fee: this.data.paymoney,
        openid: app.globalData.userInfo.openId
      }
      $.httpPost("build_payorderparam", par, (data, err) => {
        let that = this
        if (data.result == 'success') {
          app.wxPays({
            data,
            success: function () {
              wx.showToast({
                title: '支付成功哈',
              })
              that.setData({
                paymoney:''
              })
            },
            fail: function () {
              wx.showToast({
                title: '支付失败了呢',
              })
            }
          })
        }
      })
    }else{
      wx.showToast({
        title: '不能是空',
      })
    }
    
  }
})
